home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / daemons / nfs / nfs-serv.2be / nfs-serv / nfs-server-2.2beta16 / auth.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-21  |  4.2 KB  |  137 lines

  1. /*
  2.  * auth.h    This module takes care of request authorization.
  3.  *
  4.  * Authors:    Mark A. Shand, May 1988
  5.  *        Rick Sladkey, <jrs@world.std.com>
  6.  *        Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  7.  *
  8.  *        Copyright 1988 Mark A. Shand
  9.  *        This software maybe be used for any purpose provided
  10.  *        the above copyright notice is retained.  It is supplied
  11.  *        as is, with no warranty expressed or implied.
  12.  */
  13.  
  14. /* Global AUTH variables. */
  15. extern int            allow_non_root;
  16. extern int            promiscuous;
  17. extern int            re_export;
  18. extern int            trace_spoof;
  19. extern exportnode        *export_list;
  20. extern uid_t            cred_uid, auth_uid;
  21. extern gid_t            cred_gid, auth_gid;
  22.  
  23. #if defined(linux) && defined(i386) && !defined(HAVE_SETFSUID)
  24. #   define MAYBE_HAVE_SETFSUID
  25. #endif
  26.  
  27. #ifdef MAYBE_HAVE_SETFSUID
  28. extern int            have_setfsuid;
  29. #endif
  30.  
  31. /*
  32.  * These externs are set in the dispatcher (dispatch.c) and auth_fh
  33.  * (nfsd.c) so that we can determine access rights, export options,
  34.  * etc. pp.
  35.  */        
  36. extern struct nfs_client    *nfsclient;
  37. extern struct nfs_mount        *nfsmount;
  38. /* extern struct svc_req         *svc_rqstp; */
  39.  
  40. /*
  41.  * These are the structures used by the authentication module.
  42.  */
  43. typedef struct nfs_options {
  44.     enum { map_daemon, identity }
  45.                 uidmap;        /* uid/gid mapping behavior */
  46.     int            root_squash;
  47.     int            all_squash;
  48.     int            secure_port;
  49.     int            read_only;
  50.     int            link_relative;
  51.     int            noaccess;
  52.     uid_t            nobody_uid;
  53.     gid_t            nobody_gid;
  54. } nfs_options;
  55.  
  56. typedef struct nfs_mount {
  57.     struct nfs_mount    *next;
  58.     struct nfs_client    *client;
  59.     int            length;
  60.     char            *path;
  61.     nfs_options        o;
  62. } nfs_mount;
  63.  
  64. typedef struct nfs_client {
  65.     struct nfs_client    *next;
  66.     struct in_addr        clnt_addr;
  67.     struct in_addr        clnt_mask;
  68.     char            *clnt_name;
  69.     unsigned short        flags;
  70.     nfs_mount        *m;
  71.  
  72.     /* Things that will also go here:
  73.      *  -    uid/gid map for those who want to run ugidd. 
  74.      *  -    encryption info for the file handle
  75.      */
  76.     struct ugid_map        *umap;
  77. } nfs_client;
  78.  
  79. #define AUTH_CLNT_WILDCARD    0x0001
  80. #define AUTH_CLNT_ANONYMOUS    0x0002
  81. #define AUTH_CLNT_NETGROUP    0x0004
  82. #define AUTH_CLNT_NETMASK    0x0008
  83. #define AUTH_CLNT_DEFAULT    0x0010
  84.  
  85. #ifndef ROOT_UID
  86. #define ROOT_UID        0
  87. #endif
  88.  
  89. #define AUTH_UID_NONE        ((uid_t)-1)
  90. #define AUTH_GID_NONE        ((uid_t)-1)
  91. #define AUTH_UID_NOBODY        ((uid_t)-2)
  92. #define AUTH_GID_NOBODY        ((uid_t)-2)
  93.  
  94. /* Global Function prototypes. */
  95. extern _PRO( void       auth_init, (char *fname)            );
  96. extern _PRO( void       auth_init_lists, (void)                );
  97. extern _PRO( void    auth_free_lists, (void)                );
  98. extern _PRO( nfs_client *auth_clnt, (struct svc_req *rqstp)        );
  99. extern _PRO( nfs_mount  *auth_path, (nfs_client *, struct svc_req *, char *));
  100. extern _PRO( void       auth_user, (nfs_mount *, struct svc_req *)    );
  101.  
  102. extern _PRO( nfs_client *auth_get_client, (char *)            );
  103. extern _PRO( nfs_mount  *auth_match_mount, (nfs_client *, char *)    );
  104. extern _PRO( nfs_client *auth_known_clientbyaddr, (struct in_addr)    );
  105. extern _PRO( nfs_client *auth_known_clientbyname, (char *)        );
  106. extern _PRO( nfs_client *auth_unknown_clientbyaddr, (struct in_addr)    );
  107. extern _PRO( nfs_client *auth_create_client, (const char *, struct hostent *));
  108. extern _PRO( nfs_client *auth_create_default_client, (void)        );
  109. extern _PRO( nfs_mount  *auth_add_mount, (nfs_client *, char *)        );
  110. extern _PRO( void       auth_check_all_wildcards, (void)        );
  111. extern _PRO( void       auth_check_all_netgroups, (void)        );
  112. extern _PRO( void       auth_check_all_netmasks, (void)            );
  113.  
  114. /* This function lets us set our euid/fsuid temporarily */
  115. extern _PRO( void       auth_override_uid, (uid_t)            );
  116.  
  117. /* Prototypes for ugidd mapping */
  118. extern _PRO( uid_t    ruid, (uid_t, nfs_mount *, struct svc_req *)    );
  119. extern _PRO( gid_t    rgid, (gid_t, nfs_mount *, struct svc_req *)    );
  120. extern _PRO( uid_t    luid, (uid_t, nfs_mount *, struct svc_req *)    );
  121. extern _PRO( gid_t    lgid, (gid_t, nfs_mount *, struct svc_req *)    );
  122. extern _PRO( void    ugid_free_map, (struct ugid_map *)        );
  123. extern _PRO( void    ugid_map_uid, (nfs_mount *, uid_t fm, uid_t to)    );
  124. extern _PRO( void    ugid_map_gid, (nfs_mount *, gid_t fm, gid_t to)    );
  125.  
  126. #if 0
  127. #define ruid(u, mp, x)        (u)
  128. #define rgid(g, mp, x)        (g)
  129. #define luid(u, mp, x)    \
  130.     (((!(u) && (mp)->o.root_squash) || (mp)->o.all_squash)? nobody_uid:(u))
  131. #define lgid(g, mp, x)    \
  132.     (((!(g) && (mp)->o.root_squash) || (mp)->o.all_squash)? nobody_gid:(g))
  133. #define ugid_free_map(map)    /* NOP */
  134. #endif
  135.  
  136. /* End of auth.h. */
  137.